import type {AddressItemType} from "@/types/user";

export const assembleAddress = (item: AddressItemType): string => {
    return item.province + item.city + item.area + item.detail
}

/**
 * 分割价格的数据
 * @param price
 * @param intPater
 */
export const slicePrice = (price: string, intPater: boolean): string => {
    // 将price隐式转换成string
    const convertPrice = price + ''
    const dotIdx = convertPrice.indexOf(".")
    console.log("slice price trace: price: ", convertPrice, "dot idx: ", dotIdx)
    if (intPater) {
        if (dotIdx === -1) {
            return convertPrice
        }
        return convertPrice.slice(0, dotIdx)
    }
    if (dotIdx === -1) {
        return '00'
    }
    return convertPrice.slice(dotIdx)
}